/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package session02;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author macbookpro
 */
public class AccountWithdraw1 implements Runnable {

    private Account a;

    public AccountWithdraw1(Account a) {
        this.a = a;
    }

    @Override
    public void run() {
        synchronized (a) {
            if (a.getBalance() < 100) {
                try {
                    a.wait();
                } catch (InterruptedException ex) {
                    Logger.getLogger(AccountWithdraw1.class.getName()).log(Level.SEVERE, null, ex);
                }
            }

            a.withdraw(100);
        }
        System.out.print("withdraw 100");
        System.out.println(", balance: " + a.getBalance());
    }
}
